<template>
	<el-dialog
		:title="dialog.title"
		v-model="dialog.visible"
		:append-to-body="true"
		:close-on-click-modal="false"
		width="950px"
		top="0"
	>
		<div>
			<select-goods-table-goodsid ref="selectGoodsTable" @select="selectionSelect" />
		</div>
		<template #footer>
			<el-button @click="cancle" size="small">取消</el-button>
			<el-button type="primary" @click="doSubmit" size="small">选择勾选</el-button>
		</template>
	</el-dialog>
</template>

<script>
import SelectGoodsTableGoodsid from "./selectGoodsTableByGoodsId.vue";
export default {
	name: "select-dialog-goodsid",
	components: {
		SelectGoodsTableGoodsid
	},
	emits: ["select"],
	data() {
		return {
			dialog: {
				title: "选择商品",
				visible: false
			},
			goodsData: []
		};
	},
	methods: {
		selectionSelect(selections) {
			console.log(selections);
			this.goodsSelect = selections;
		},
		/**
		 * @description 打开面板
		 */
		open() {
			this.dialog.visible = true;
		},
		/**
		 * @description 关闭面板
		 */
		cancle() {
			this.dialog.visible = false;
		},
		/**
		 * @description 初始化表单为新建模式
		 */
		async create(data = {}) {
			console.log(data);
			this.open();
		},
		doSubmit() {
			console.log(this.goodsSelect);
			this.$emit(
				"select",
				this.goodsSelect.map((e) => e.id)
			);
			this.cancle();
		}
	}
};
</script>

<style scoped></style>
